/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufba.lasid.cloud;

import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang.StringUtils;

/**
 *
 * @author aliriosa
 */
public class Datacenter {

    private String id;
    private List<Node> nodes;

    public Datacenter(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public List<Node> getNodes() {
        return nodes;
    }

    public void setNodes(List<Node> nodes) {
        this.nodes = nodes;
    }

    public void addNode(Node node) {
        if (this.nodes == null) {
            this.nodes = new ArrayList<Node>();
        }
        this.nodes.add(node);
    }

    public Node getNode(String address) {
        for (Node node : this.nodes) {
            if (StringUtils.equalsIgnoreCase(node.getAddress(), address)) {
                return node;
            }
        }
        return null;
    }
}
